import {
	getPhoneCode
} from "@/api/login";

let d_times = 60
export default {
	data() {
		return {
			times: d_times,
			smsState: false,
		}
	},
	methods: {
		start() {
			this.smsState = true;
			const inter = setInterval(() => {
				this.times = this.times - 1;
				if (this.times <= 0) {
					this.smsState = false;
					this.times = d_times;
					clearInterval(inter);
				}
			}, 1000);
		},
		sendCaptcha(mobile) {
			console.log(2222222222);
			if (this.smsState) return
			getPhoneCode({
				phone: mobile
			}).then(res => {
				this.$toast('发送验证码成功！')
				this.start()
			}, error => {
				console.log(error);
			})
		}
	}
}